package package007

import fundation.gsonPrintln
import org.junit.Test

/**
 * @author futao
 * Created on 2017/11/15 - 14:50.
 */

/**
 * 使用解构声明来返回多个值
 */
class MyPoint(val x: Int, val y: Int) {
    operator fun component1() = x
    operator fun component2() = y
}

/**
 * 默认实现componentN解构声明
 */
data class Operation(val x: Int, val y: Int, val z: Int, val a: Int)

class TestCase004 {
    /**
     * 传入MyPoint(x，y)   计算出相应的 + - * /
     */
    fun test(argument: MyPoint): Operation {
        with(argument) {
            return Operation(x + y, x - y, x * y, x / y)
        }
    }

    @Test
    fun testCase001() {
        MyPoint(100, 200)
        val (x, y, z, a) = test(MyPoint(2, 6))
        gsonPrintln(test(MyPoint(2, 6)))

    }
}


data class NameComponents(val name: String, val extension: String, val str1: String, val str2: String, val str3: String, val str4: String)

class TestClass001 {
    @Test
    fun testCase001() {
        gsonPrintln(splitFileName("000.666.2222"))
        val (name, extension, str1, str2, str3, str4) = splitFileName("6666,66,66,6,6,66,6,6,6,6,66")
        val listOf = listOf("10", "10", "10", "10", "10", "10", "10", "10")
        for ((i,e) in listOf.withIndex()){

        }
    }

    fun splitFileName(fileName: String): NameComponents {
        val list = fileName.split(".", limit = 16)
//        gsonPrintln(list.size)
        return NameComponents(list[0], list[1],list[2],list[2],list[2],list[2])
    }
}